home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 2000 #2 / Sun Solutions CD (Volume 2 2000)(Special Focus - Java Technologies)(Disc 1).ISO / products / Software / BostonBusinessComputing / bbc / install < prev    next >
Text File  |  2000-02-11  |  6KB  |  258 lines

  1. #!/bin/sh
  2.  
  3.  
  4. test "/$argv[0]" = "/" && exec /bin/sh $0 $argv
  5. (a=1; unset a) 2>/dev/null || {
  6.         [ "`uname -s 2>/dev/null`" = "ULTRIX" ] &&\
  7.     exec /bin/sh5 -$- $0 ${@+"$@"}
  8. }
  9.  
  10. umask 22
  11.  
  12. options="help
  13. nocheck
  14. nolic
  15. noprev
  16. noquick
  17. quick
  18. rootok
  19. noasklic"
  20.  
  21. idlist() {
  22.     awk '/^[A-Za-z][^     ]*[     ]*-/ {print $1}' \
  23.     ${@+"$@"} | sort -u
  24. }
  25.  
  26. prodinfo() {
  27.     arg1=$1
  28.     lookfor=$1
  29.     NPRODS=0
  30.     PRODUCTS=""
  31.     NETWORKED=""
  32.     PRODDISTFILES=""
  33.     for f in $instdir/ID.*; do
  34.     case $f in "$instdir/ID.*") return 1;; esac
  35.     set -$- `awk 'NR==1{print $2, $3, $4, $5}' $f`
  36.     PRODUCTS="$PRODUCTS $1"
  37.     NPRODS=`expr $NPRODS + 1`
  38.     [ "$4" != 'N' ] && NETWORKED=y
  39.     if [ -z "$lookfor" -o "$1" = "$lookfor" ]; then
  40.         lookfor=$1
  41.         PRODNAME=$1
  42.         PRODDISP="$1"
  43.         PRODVER=$3
  44.         PRODNN=$4
  45.         PRODFILE=`echo $PRODNAME | tr '[A-Z]' '[a-z]' | sed 's/[^a-z0-9]//g'`
  46.     fi
  47.     done
  48.  
  49.     if [ -z "$arg1" ]; then
  50.     PRODDISTFILES="`idlist $instdir/ID.*`"
  51.     if [ "$NPRODS" -gt 1 ]; then
  52.         PRODNAME='the products'
  53.         PRODDISP='the products'
  54.         PRODVER=''
  55.         PRODNN=''
  56.         PRODFILE=''
  57.     fi
  58.     fi
  59.  
  60.     set -$- $PRODUCTS
  61.     export PRODNAME PRODDISP PRODVER PRODNN PRODFILE PRODUCTS \
  62.        PRODDISTFILES NPRODS NETWORKED
  63. }
  64.  
  65. setprot() {
  66.     awk '/^[A-Za-z][^     ]*[     ]*-/ {file = 1}
  67.      {if (!file) next; file = 0; if (f[$1]) next; f[$1] = 1}
  68.      {if ((s = index($1, "/")) && !f[d = substr($1, 1, s - 1)]) {
  69.           f[d] = 1; c[755] = c[755] " " d }}
  70.      /[Mm]essage/||/[Mm]anual/||/[Dd]iskette/||/[Tt]his file/||/[Rr]elease notes/ {perm = 444}
  71.      /[Ii]nitialization/||/[Ss]tandard/||/[Dd]efinitions/||/[Cc]onfig/||/[Hh]elp text/ {perm = 644}
  72.      /[Ee]xecutable/||/[Dd]aemon/ {perm = 555}
  73.      /[Pp]rocedure/||/[Ss]cript/||/[Ff]ilter/ {perm = 755}
  74.      /dist\// {if (perm >= 600) perm -= 200}
  75.      {c[perm] = c[perm] " " $1}
  76.      END {for (m in c) print "chmod " m c[m]}' \
  77.     $instdir/ID.* | (cd bbc; sh -s)
  78. }
  79.  
  80. unc() {
  81.     for f in `find $instdir -name '*.Z' -print`; do
  82.     case "$f" in
  83.         *.tar.?) compress -dfc $f | tar xf -
  84.              rm -f $f
  85.              ;;
  86.         *)       compress -df $f
  87.              ;;
  88.     esac
  89.     done
  90. }
  91.  
  92. bye() {
  93.     wait
  94.     exit 1
  95. }
  96.  
  97. instdir=`dirname $0`
  98. case "$instdir" in
  99. ''|.)    instdir=`pwd`;;
  100. /*)    ;;
  101. *)    instdir=`(cd $instdir; pwd)`;;
  102. esac
  103.  
  104. for f do
  105.     eval $f=:
  106. done
  107.  
  108. for f in $options; do
  109.     eval '[ -z "$'$f'" ] && '$f'=false'
  110. done
  111.  
  112. quickarg=:
  113. $noquick && quickarg=false
  114.  
  115. PATH=$instdir:$PATH; export PATH
  116.  
  117. $help && {
  118.     tbput display "The following options are available:
  119. $options
  120. "
  121.     exit 0
  122. }
  123.  
  124. BBCFILES=$instdir; export BBCFILES
  125. [ -d $BBCFILES ] || {
  126.     echo "This program must be run from the directory (/tmp) in which you extracted
  127. files using the 'tar' command.
  128.  
  129. Please try again from that directory."
  130.     exit 1
  131. }
  132.  
  133. trap bye 2
  134. whoami=`(whoami) 2>/dev/null || (id | sed 's/^[^(]*(\([^)]*\)).*/\1/')`
  135.  
  136. error=false
  137. $rootok || if [ "$whoami" != "root" ] ; then
  138.     tbput clear display 'You must be logged in as \broot\B to successfully perform this
  139. install procedure.  If you are not logged in as super user, you will see
  140. error messages displayed due to the placement of the distribution files.
  141.  
  142. If you \breally\B think this will not be a problem you can restart the
  143. installation procedure with "'$0' rootok".
  144.  
  145. '
  146.     exit 1
  147. fi
  148.  
  149. $nocheck || while : ; do
  150.     if (:>$instdir/.rw) 2>/dev/null; then
  151.     rm $instdir/.rw
  152.     rw=:
  153.     chmod 755 $instdir/compress $instdir/tbput 2>/dev/null
  154.     else
  155.     rw=false
  156.     fi
  157.     tbput clear display "Verifying your distribution..."
  158.     unc
  159.     prodinfo
  160.     $rw && setprot
  161.  
  162.     if [ -z "$NPRODS" -o "$NPRODS" -lt 1 ]; then
  163.     tbput display "
  164. Error attempting to process the files in this distribution.
  165. No product files detected.
  166. "
  167.     error=:
  168.     break
  169.     fi
  170.  
  171.  
  172.     msg="
  173. The following files are missing or unreadable:
  174. "
  175.     for f in $PRODDISTFILES; do
  176.     matched=false
  177.     for g in $instdir/$f; do
  178.         [ -r $g ] && {
  179.         matched=:
  180.         break
  181.         }
  182.     done
  183.     $matched && continue
  184.     tbput display "$msg"
  185.     msg=''
  186.     echo "            $f"
  187.     done
  188.  
  189.     if [ -n "$msg" ]; then
  190.     msg="done"
  191.     else
  192.     msg="
  193. It appears that some expected files are missing from the
  194. $instdir directory.  The list of expected files was
  195. derived from any ID.* files in this directory.
  196.  
  197. If you received multiple diskettes containing your product
  198. distribution please make sure you have extracted all files from
  199. all of the diskettes before proceeding with this installation.
  200.  
  201. To extract the files use the tar command documented in the
  202. Installation Guide.
  203.  
  204. If you think that you have extracted all files correctly,
  205. please call our Technical Support department."
  206.     error=:
  207.     fi
  208.     tbput display "$msg
  209. "
  210.     break
  211. done
  212.  
  213. $error && exit 1
  214.  
  215. $noquick || $quick || tbput display '
  216. A quick installation automatically places your products in default
  217. locations inferred from your system layout.  A detailed installation
  218. allows you to override these defaults.  To perform a detailed
  219. installation, press CTRL-C now and restart the installation with
  220. "'$0' noquick".
  221.  
  222. Press ENTER to perform a quick installation: ' pause
  223.  
  224. tbput clear
  225. bbc setup $quickarg $noprev
  226.  
  227. $nolic || {
  228.     if $noasklic; then
  229.     bbc license :
  230.     else
  231.     licensing=:
  232.     trap 'licensing=false' 2
  233.     tbput display '
  234. Press ENTER to continue with product licensing
  235. or abort now with CTRL-C: ' pause clear
  236.     trap bye 2
  237.     $licensing && bbc license :
  238.     fi
  239. }
  240. : ${BBCETC=/etc}
  241. : ${BBCLICDIR=$BBCETC/bbc}
  242. . $BBCLICDIR/config
  243. torun=; for f in $BBCFILES/ID.*; do
  244.     name=`expr $f : '.*/ID\.\(.*\)'`
  245.     bin=`sed -ne 's/\(.*\)\.x.*- '$name' executable/\1/p' $f`
  246.     torun="$torun
  247. Type \\b$bin\\B to run $name."
  248. done
  249.  
  250. tbput display "Installation is complete.
  251. $torun
  252. Type \\bbbc contact\\B to view Boston Business Computing contact information.
  253.  
  254. Please take a moment to inspect the README.* files in $BBC.
  255. They contain valuable information about your installation that is not
  256. necessarily covered in your manual.
  257. "
  258.